Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_subnet: Support for multiple prefixes with address_prefixes #6493

Merged
merged 1 commit into from
Apr 27, 2020
Merged

azurerm_subnet: Support for multiple prefixes with address_prefixes #6493

merged 1 commit into from
Apr 27, 2020

Conversation

fabianofranz
Copy link
Contributor

Splitting #6148 into separate PR's

The azure subnet resource supports addressPrefix when one prefix is available and addressPrefixes when two or or more are set (for instance, when configuring an ipv4 and ipv6 dual stack configuration for a network). Update azurerm_subnet to allow either address_prefix or address_prefixes as input, where the latter is a list of string. Check that at least one is set, and mark the older address_prefix as deprecated.

The data source for subnet is modified to always return address_prefixes to simplify retrieval (although this could be changed to always return the first address prefix as address_prefix).

Today, if two prefixes are specified via CLI or Azure UI the data source returns no address_prefix and it is not possible to create a new subnet with two prefixes via Terraform.

Fixes #5140

@fabianofranz
Copy link
Contributor Author

@mbfrahry PTAL

Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @fabianofranz, so the tests panic when using address_prefixes

TestAccDataSourceAzureRMSubnet_basic_addressPrefixes
panic: interface conversion: interface {} is nil, not string

goroutine 529 [running]:
github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/network.resourceAzureSubnetHash(0x4aca700, 0xc0016d8600, 0xc0009c9210)
	/Users/mbfrahry/workspace/gocode/src/github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/network/resource_arm_virtual_network.go:445 +0x276

This is because we're assuming address_space is being set in the Hash for subnets under virtual networks. We'll just need to confirm that that value is ok before setting it. It'll be just like security_group a couple lines below this line https://github.com/terraform-providers/terraform-provider-azurerm/blob/master/azurerm/internal/services/network/resource_arm_virtual_network.go#L445

The azure subnet resource supports addressPrefix when one prefix is available and addressPrefixes when two or or more are set (for instance, when configuring an ipv4 and ipv6 dual stack configuration for a network). Update azurerm_subnet to allow either address_prefix or address_prefixes as input, where the latter is a list of string. Check that at least one is set, and mark the older address_prefix as deprecated.

The data source for subnet is modified to always return address_prefixes to simplify retrieval (although this could be changed to always return the first address prefix as address_prefix).

Today, if two prefixes are specified via CLI or Azure UI the data source returns no address_prefix and it is not possible to create a new subnet with two prefixes via Terraform.

Fixes #5140
@fabianofranz
Copy link
Contributor Author

@mbfrahry oops, my bad, thanks for pointing out. Fixed.

Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mbfrahry mbfrahry changed the title subnet: Support address_prefixes for multiple prefixes (ipv6) azurerm_subnet: Support for multiple prefixes with address_prefixes Apr 27, 2020
@mbfrahry mbfrahry merged commit c1d8f52 into hashicorp:master Apr 27, 2020
mbfrahry added a commit that referenced this pull request Apr 27, 2020
@mbfrahry mbfrahry added this to the v2.8.0 milestone Apr 27, 2020
@ghost
Copy link

ghost commented May 1, 2020

This has been released in version 2.8.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.8.0"
}
# ... other configuration ...

dghubble added a commit to poseidon/typhoon that referenced this pull request May 19, 2020
* Update Azure subnet `address_prefix` to `azure_prefixes` list
* Fix warning that `address_prefix` is deprecated
* Require `terraform-provider-azurerm` v2.8.0+ (action required)

Rel: hashicorp/terraform-provider-azurerm#6493
dghubble added a commit to poseidon/typhoon that referenced this pull request May 19, 2020
* Update Azure subnet `address_prefix` to `azure_prefixes` list
* Fix warning that `address_prefix` is deprecated
* Require `terraform-provider-azurerm` v2.8.0+ (action required)

Rel: hashicorp/terraform-provider-azurerm#6493
dghubble-robot pushed a commit to poseidon/terraform-azure-kubernetes that referenced this pull request May 25, 2020
* Update Azure subnet `address_prefix` to `azure_prefixes` list
* Fix warning that `address_prefix` is deprecated
* Require `terraform-provider-azurerm` v2.8.0+ (action required)

Rel: hashicorp/terraform-provider-azurerm#6493
@ghost
Copy link

ghost commented May 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators May 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Subnets with multiple addressPrefixes cannot be used as a source or created
2 participants